class People(object):
    # 类属性
    name = "小王"

    #  定义类方法
    @classmethod                                   # 装饰器
    def sleep(cls):                                # cls为类对象
        # 在类的方法里调用类属性 格式: 类名.类属性名,这里的类名可用cls
        print("{} is sleeping".format(cls.name))


    def __init__(self, age):
        self.age = age

    def work(self):
        # 调用类属性
        if self.age > 18:
            # 在对象里调用类属性,格式: 类名.类属性名
            print("{} is working".format(People.name))
        else:
            print("{} is not working".format(People.name))

    def eat(self):
        print("{} is eating".format(People.name))

# 调用类方法,类方法不需要实例化对象 格式: 类名.类方法名()
People.sleep()
people01 = People(20)
people01.work()
people01.eat()
